import QtQuick
import QtQuick.Layouts
import FluentUI

// 登录功能区
FluRectangle {
    id: loginRect

    Layout.fillWidth: true
    Layout.fillHeight: true
    color: "transparent"

    // 字体大小因子，基于loginRect的高度
    property real fontSizeFactor: mainWindow.width / 1200
    // 欢迎回来标题
    Text {
        text: "欢迎回来"
        font.pointSize: 15 * fontSizeFactor
        font.family: "MiSans"
        font.weight: Font.DemiBold
        color: "#0A1629"
        anchors.horizontalCenter: parent.horizontalCenter
        y: parent.height * 0.15
    }

    // 登录区域
    ColumnLayout {
        y: parent.height * 0.28
        anchors.horizontalCenter: parent.horizontalCenter
        spacing: parent.height * 0.04

        // 账号输入区
        Column {
            spacing: parent.height * 0.01
            Text {
                text: "账号"
                font.pointSize: 9 * fontSizeFactor
                font.family: "MiSans"
                color: "#7D8592"
            }

            FluTextBox {
                id: accountBox
                width: loginRect.width * 0.618
            }
        }

        // 密码输入区
        Column {
            spacing: parent.height * 0.01
            Text {
                text: "密码"
                font.pointSize: 9 * fontSizeFactor
                font.family: "MiSans"
                color: "#7D8592"
            }

            FluPasswordBox {
                id: passwordBox
                width: loginRect.width * 0.618
            }
        }

        // 其他功能区
        RowLayout {
            Layout.preferredWidth: loginRect.width * 0.618
            FluCheckBox {
                text: "记住我"
                font.pointSize: 9 * fontSizeFactor
                font.family: "MiSans"
                textColor: "#7D8592"
                checkedColor: "#3F8CFF"
                anchors.left: parent.left
            }

            FluTextButton {
                text: "忘记密码"
                font.pointSize: 9 * fontSizeFactor
                font.family: "MiSans"
                textColor: "#7D8592"
                anchors.right: parent.right
            }
        }

        // 登录按钮
        FluFilledButton {
            id: loginButton
            text: "立即登录"
            font.family: "MiSans"
            font.pointSize: 9 * fontSizeFactor
            normalColor: "#3F8CFF"
            Layout.preferredWidth: loginRect.width * 0.618
            Layout.preferredHeight: loginRect.height * 0.05
            onClicked: {
                FluRouter.navigate("/mainWindow");
                mainWindow.close();
            }
        }
    }

    // 前往注册按钮
    FluTextButton {
        text: "没有账号？前往注册"
        font.pointSize: 10 * fontSizeFactor
        font.family: "MiSans"
        textColor: "#7D8592"
        anchors.bottom: parent.bottom
        anchors.right: parent.right
    }
}
